import java.io.IOException;
import java.net.*;
import java.util.Scanner;

public class Client {

	public static void main(String[] args) throws SocketException, UnknownHostException, IOException {
		//初始化连接服务器ServerSocket
		System.out.print("please input server inet4 address:");
		Scanner scanner = new Scanner(System.in);
		String serverAddress = scanner.nextLine();
		DatagramSocket socket = new DatagramSocket(); //随机端口号
		while(true) {
			String data= scanner.nextLine();
			byte[] b = data.getBytes();
			if("Esc".equals(data)) {
				break;
			}
			DatagramPacket packet = new DatagramPacket(b, b.length, InetAddress.getByName(serverAddress), 8888);
			socket.send(packet);
		}
		socket.close();
	}
}